package org.dalmatian.common.kafka.config;

import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.Props;



/**
 * @author noear 2024/12/6 created
 * 暂时不支持 消费
 */
@Configuration
public class KafkaConfig {
    @Bean
    public KafkaProducer<String, String> producer(@Inject("${solon.kafka.properties}") Props common,
                                                  @Inject("${solon.kafka.producer}") Props producer) {
        producer.putAll(common);
        return new KafkaProducer<>(producer);
    }

    @Bean
    public KafkaConsumer<String, String> consumer(@Inject("${solon.kafka.properties}") Props common,
                                                  @Inject("${solon.kafka.consumer}") Props consumer) {
        consumer.putAll(common);
        return new KafkaConsumer<>(consumer);
    }
}